#!/usr/bin/env sh
SOURCE_FILE="go_build_linux_amd64_main"
DEST_FILE="mini-upload-prod"

supervisorctl stop $DEST_FILE
if [ -e "$SOURCE_FILE" ]; then
  cp $SOURCE_FILE $DEST_FILE
  rm $SOURCE_FILE
fi
chmod +x $DEST_FILE
rm -rf "log/*.log"
supervisorctl start $DEST_FILE
sleep 1
PID=$(pgrep -f ${DEST_FILE})
echo "$DEST_FILE PID: $PID"